﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>RSS de EstasEnPosse.com.ar</title>
<link href="../EstilosPHP.css" rel="stylesheet" type="text/css" />

</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="40%"><div align="left"><img src="../IMAGENES/LogoMaster.jpg" width="274" height="128" /></div></td>
    <td width="60%"><div align="left"><img src="../IMAGENES/justiniano.jpg" width="125" height="229" /></div></td>
  </tr>
</table>
<p>&nbsp;</p>
<p><span class="EstiloNormal">
  <?php 

function sanear_string($string)
{
 
    $string = trim($string);
    //Esta parte se encarga de eliminar cualquier caracter extraño
   
 	$string = str_replace(array("&ntilde;"), 'ñ',$string);
  	$string = str_replace(array("&Ntilde;"), 'Ñ',$string);
 	$string = str_replace(array("&aacute;"), 'á',$string);
    $string = str_replace(array("&Aacute;"), 'Á',$string);
	$string = str_replace(array("&eacute;"), 'é',$string);
	$string = str_replace(array("&Eacute;"), 'É',$string);
	$string = str_replace(array("&iacute;"), 'í',$string);
	$string = str_replace(array("&Iacute;"), 'Í',$string);
	$string = str_replace(array("&oacute;"), 'ó',$string);
	$string = str_replace(array("&Oacute;"), 'Ó',$string);
	$string = str_replace(array("&uacute;"), 'ú',$string);
	$string = str_replace(array("&Uacute;"), 'Ú',$string);
	$string = str_replace(array("&acute;"), "'",$string);
	$string = str_replace(array("&lsquo;"), "'",$string);
	$string = str_replace(array("&rsquo;"), "'",$string);
	
	$string = str_replace(array("&bull;"), '•',$string);	   
	$string = str_replace(array("&nbsp;"), ' ',$string);
    $string = str_replace(array("&iquest;"), '¿',$string);
    $string = str_replace(array("&rdquo;"), '"',$string);
    $string = str_replace(array("&hellip;"), '...',$string);
    $string = str_replace(array("&ldquo;"), '"',$string);
    $string = str_replace(array("&ordm;"), 'º',$string);
	$string = str_replace(array("&iexcl;"), '¡',$string);
	$string = str_replace(array("&Uuml;"), 'Ü',$string);
	$string = str_replace(array("&uuml;"), 'ü',$string);
	$string = str_replace(array("&ordf;"), 'ª',$string);
	$string = str_replace(array("&ndash;"), '-',$string);
	$string = str_replace(array("&mdash;"), '—',$string);
	$string = str_replace(array("&deg;"), '°',$string);
	$string = str_replace(array("&lt;"), '<',$string);
	$string = str_replace(array("&gt;"), '>',$string);
	$string = str_replace(array("&frasl;"), '/',$string);
	$string = str_replace(array("&reg;"), '®',$string);
	$string = str_replace(array("&amp;"), '&',$string);
	$string = str_replace(array("&quot;"), '"',$string);
	$string = str_replace(array("&middot;"), '·',$string);


$string = preg_replace("/(<(\/*)iframe([^<>]*)+>)/i", ' **** **** ESTA NOTA POSEE CONTENIDO QUE SE VISUALIZA CORRECTAMENTE EN EL SITIO WEB ****. ****',$string);
$string = preg_replace("/(<(\/*)div([^<>]*)+>)/i", '',$string);
$string = preg_replace("/(<(\/*)ul([^<>]*)+>)/i", '',$string);
$string = preg_replace("/(<(\/*)li([^<>]*)+>)/i", '',$string);
$string = preg_replace("/(<(\/*)p([^<>]*)+>)/i", '',$string);
$string = preg_replace("/(<(\/*)span([^<>]*)+>)/i", '',$string);
$string = preg_replace("/(<(\/*)img([^<>]*)+>)/i", '',$string);
$string = preg_replace("/(<(\/*)class([^<>]*)+>)/i", '',$string);
$string = preg_replace("/(<(\/*)script([^<>]*)+>)/i", '',$string);
$string = preg_replace("/(<(\/*)blockquote([^<>]*)+>)/i", ' **** ESTA NOTA POSEE CONTENIDO QUE SE VISUALIZA CORRECTAMENTE EN EL SITIO WEB. ****',$string);
$string = preg_replace("/(<(\/*)style([^<>]*)+>)/i", '',$string);
$string = preg_replace("/(<(\/*)a href([^<>]*)+>)/i", '',$string);
$string = preg_replace("/(<(\/*)a([^<>]*)+>)/i", '',$string);
$string = preg_replace("/(<(\/*)em([^<>]*)+>)/i", '',$string);
$string = preg_replace("/(<(\/*)function([^<>]*)+>)/i", ' **** **** ESTA NOTA POSEE CONTENIDO QUE SE VISUALIZA CORRECTAMENTE EN EL SITIO WEB ****. ****',$string);

	
 $string = str_replace(
    /*   array("<b>","</b>","<a href=","</a","</a>","<em>","</em>","¨","~","<p>","</p>","</strong>","<strong>","<br>","</br>","<br","</br","<span","<span style","</span>","·","^", "`","¨", "´","<img","/>","<img src=","color:","#","<div>","</div>","<ul>","</ul>","<li>","<li","</li>","style=&quot; ff6600;&quot;>","style",">","=","ff6600","ff9900","FF6600","FF9900","&quot;","<p align'right'","<p align","'right'","'left'","<p","<p 'text-align: center;'","<iframe src","</iframe>","</iframe","height","width",), '',$string);
		 */
		  array("¨","~","</strong>","<strong>","<br>","</br>","<br","</br","<span","<span style","</span>","·","^", "`","¨", "´",">","#ff6600","#ff9900","#FF6600","#FF9900","<p align'right'","<p align","'right'","'left'","<p","<p 'text-align: center'","height","width","frameborder='0'"), '',$string);
 return $string; 
}
  
  $hora = date("h:i:s");
  $dia = date("d");
  $nombreDia = date("I");
  $mes = date("m");
  $anio = date("Y");
  $fecha = $anio."-".$mes."-".$dia;
  $hasta = date("d/m/Y") + 15;
  $diaHoy = date("d");
  $nombreDia = date("D");
  $mesHoy = date("M");
  $anioHoy = date("Y");
  $horaHoy = date("h:i:s");
  
$fechaCreado = date("Y/m/d - h:i:s");
echo "Último Creado: a las ".$hora." Dia: ".$fecha."<br><br>";

echo "Archivo: <strong><a href='http://www.estasenposse.com.ar/RSS/RSSEstasEnPosse.xml'>RSSEstasEnPosse.xml</a></strong> ";
$buffer = '<?xml version="1.0" encoding="UTF-8" ?><rss version="2.0"><channel>';
	$buffer = $buffer.'<title>RSS EstasEnPosse.com</title>';
	$buffer = $buffer.'<description>RSS oficial de EstasEnPosse.com</description>';
	$buffer = $buffer.'<link>http://www.EstasEnPosse.com/</link>';
	$buffer = $buffer.'<lastBuildDate>Wed, 02 Oct 2002 13:00:00 GMT</lastBuildDate>';
	$buffer = $buffer.'<pubRSSDate>'.$nombreDia.', '.$diaHoy.' '.$mesHoy.' '.$anioHoy.' '.$horaHoy.' +0000</pubRSSDate>';	

include ("../conexion.php");
$db = conectaDb();
$dbNoticias = $dbDb . ".NOTICIAS";  // Nombre de la tabla
$dbTipoNoticias = $dbDb . ".TIPONOTICIA";  // Nombre de la tabla
$dbFotoPrincipal = $dbDb . ".FOTOPRINCIPAL";  // Nombre de la tabla
$dbGaleria = $dbDb . ".GALERIA";  // Nombre de la tabla
//PRIMER CONSULTA, NOTA PRINCIPAL
$consulta = "SELECT *,$dbNoticias.ID AS IDNOTA FROM $dbNoticias, $dbTipoNoticias WHERE $dbNoticias.ID > 1 AND $dbNoticias.ACTIVO = 1 AND $dbNoticias.TIPO = $dbTipoNoticias.ID AND $dbNoticias.RSS = 1 ORDER BY $dbNoticias.ID DESC LIMIT 10"; 
try {
$result = $db->prepare($consulta,array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
$result->execute();
if (!$result) {
    print "<p>Error en la consulta.</p>\n";
} else {
  
    foreach ($result as $array) {
          
		  $ID = $array['IDNOTA'];
		  $Titulo = sanear_string($array['TITULO']);
		  $intro = sanear_string(substr($array['DESARROLLO'],0,200));
		  $cuerpo = sanear_string($array['DESARROLLO']);	 
		  $subtitulo = sanear_string($array['SUBTITULO']);
		  $fecha = $array['FECHA'];
		  $hora = $array['HORA'];
		  $pubdate = $fecha . ' ' . $hora;
		
		  $timestamp = strtotime($pubdate);
		  $timestamp;
		  $tipoNoticia = $array['NOMBRE'];
		  //SUBCONSULTA PARA TOMAR EL NOMBRE DEL TIPO
					$idTipo = $array['TIPO'];
					$consulta="SELECT * FROM $dbTipoNoticias WHERE ID = :id";
					try{
					$result = $db->prepare($consulta,array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
					$result->bindParam(':id', $idTipo, PDO::PARAM_INT);
					$result->execute();
					if (!$result) {
   						 print "<p>Error en la consulta.</p>\n";
					} else {
					$array = $result->fetch(PDO::FETCH_ASSOC);
					$tipo = $array['NOMBRE'];
					} 
					 } catch (PDOException $e) {
					    print $e->getMessage();
					  }
					//FIN CONSULTA PARA OBTENER NOMBRE DEL TIPO
					
		$consulta = "SELECT * FROM $dbFotoPrincipal WHERE $dbFotoPrincipal.IDCONTENIDO = :id AND TIPO = 'NOT' AND BORRADO=1";
		try {
			$result = $db->prepare($consulta,array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
			$result->bindParam(':id', $ID, PDO::PARAM_INT);
			$result->execute();
			if (!$result) {
 			   print "<p>Error en la consulta.</p>\n";
			} else {  
 			   $array = $result->fetch(PDO::FETCH_ASSOC);
				$foto = "http://www.estasenposse.com/FOTOPRINCIPAL/".$array['ARCHIVO'];
				}
 				 } catch (PDOException $e) {
  				   print $e->getMessage();
 			 }
			 
			 //ARMAR EL RSS
	$buffer = $buffer.'<item>';	
	$buffer = $buffer.'<id>'.$ID.'</id>';
	$buffer = $buffer.'<tipo>'.$tipoNoticia.'</tipo>';
	$buffer = $buffer.'<title>'.$Titulo.'</title>';
	if ($subtitulo <> "" ){ $buffer = $buffer.'<subtitle>'.$subtitulo.'</subtitle>';  }
	$buffer = $buffer.'<link>http://www.estasenposse.com/NOVEDADES/nota.php?id='.$ID.'</link>';
	$buffer = $buffer.'<description>'.$cuerpo.'</description>';
	$buffer = $buffer.'<image>'.$foto.'</image>';
	$buffer = $buffer.'<guid>unique string per item</guid>';
	$buffer = $buffer.'<pubDate>'.$pubdate.'</pubDate>';
	$buffer = $buffer.'</item>';
	
			 	 }
			}
  } catch (PDOException $e) {
    print $e->getMessage();
  }		
		
		
  $buffer = $buffer.'</channel></rss>';
  $file=fopen("RSSEstasEnPosse.xml","w+"); 
  fwrite ($file,$buffer); 
  fclose($file); 

//echo $buffer;

?> 
</span></p>
<p class="EstiloNormal">Noticias de EstasEnPosse.com: (debes copiar la siguiente url del archivo de noticias)</p>
<p><span class="EstiloNormal">Archivo de Noticias RSS:</span>
  <input name="textfield" type="text" id="textfield" value="http://www.estasenposse.com.ar/RSS/RSSEstasEnPosse.xml" size="70" />
</p>
<form id="form1" name="form1" method="post" action="">
  <label for="textarea"></label>
  <textarea name="textarea" id="textarea" cols="90" rows="20"><? echo $buffer;?></textarea>
</form>
<p>&nbsp;</p>
<p>
  <span class="EstiloNormal">
</span></p>
<!--
<p class="EstiloNormal">Agenda de eventos (Debes copiar el siguiente url del archivo de agenda de eventos):</p>
<p><span class="EstiloNormal">Archivo de Agenda</span>:
<input name="textfield" type="text" id="textfield" value="http://www.estasenposse.com.ar/RSS/RSSAgendaEstasEnPosse.xml" size="70" />
</p>
<form id="form1" name="form1" method="post" action="">
  <label for="textarea"></label>
  <textarea name="textarea" id="textarea" cols="90" rows="20"><? echo $buffer;?></textarea>
</form>
-->
</body>
</html>